<template>
  <j-modal
    :title="title"
    :width="800"
    :visible="visible"
    :confirmLoading="confirmLoading"
    switchFullscreen
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="关闭">

    <a-spin :spinning="confirmLoading">
      <a-form-model ref="form" :model="model" :rules="validatorRules">

        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="customId" label="客户ID">
          <a-input placeholder="请输入客户ID" v-model="model.customId"/>
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="customName" label="客户名称">
          <a-input placeholder="请输入客户名称" v-model="model.customName"/>
        </a-form-model-item>

        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="业务日期">
          <a-date-picker showTime valueFormat='YYYY-MM-DD' v-model="model.createDate"/>
        </a-form-model-item>

        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="发货日期">
          <a-date-picker showTime valueFormat='YYYY-MM-DD' v-model="model.ywCreateDate"/>
        </a-form-model-item>

        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="year" label="年份">
          <a-input v-model="model.year"/>
        </a-form-model-item>

        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="month" label="月份">
          <a-input v-model="model.month"/>
        </a-form-model-item>

        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="totalLine" label="金额">
          <a-input v-model="model.totalLine"/>
        </a-form-model-item>

        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="docType" label="业务单据">
          <a-input v-model="model.docType"/>
        </a-form-model-item>

        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="customerType" label="客户性质">
          <a-input v-model="model.customerType"/>
        </a-form-model-item>

        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="settleType" label="结算方式">
          <a-input v-model="model.settleType"/>
        </a-form-model-item>

        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="salesmanId" label="业务员ID">
          <a-input v-model="model.salesmanId"/>
        </a-form-model-item>

        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="salesman" label="业务员名称">
          <a-input v-model="model.salesman"/>
        </a-form-model-item>

        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zxKpman" label="区域开票员">
          <a-input v-model="model.zxKpman"/>
        </a-form-model-item>

        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zxArea" label="区域">
          <a-input placeholder="请输入区域" v-model="model.zxArea"/>
        </a-form-model-item>

        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="tranPosName" label="运输线路">
          <a-input placeholder="请输入运输线路" v-model="model.tranPosName"/>
        </a-form-model-item>

        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zxAccount" label="会计员">
          <a-input  v-model="model.zxAccount"/>
        </a-form-model-item>

      </a-form-model>
    </a-spin>
  </j-modal>
</template>

<script>
  import {httpAction} from '@/api/manage'
  import Vue from 'vue'
  import {ACCESS_TOKEN} from "@/store/mutation-types"
  import JImageUpload from '../../../../components/jeecg/JImageUpload'

  export default {
    name: 'DetailDebtCustomerModal',
    data() {
      return {
        title: '操作',
        visible: false,
        model: {},
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },

        confirmLoading: false,
        validatorRules: {},
        url: {
          add: '/com.gdztyy.modules.inca.vo/bmsDebtCustomer/add',
          edit: '/com.gdztyy.modules.inca.vo/bmsDebtCustomer/edit',
        },
      }
    },
    created() {
    },
    methods: {
      add() {
        //初始化默认值
        this.edit({})
      },
      edit(record) {
        this.model = Object.assign({}, record)
        this.visible = true
      },
      close() {
        this.$emit('close')
        this.visible = false
        this.$refs.form.clearValidate()
      },
      handleOk() {
        const that = this
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true
            let httpurl = ''
            let method = ''
            if (!this.model.id) {
              httpurl += this.url.add
              method = 'post'
            } else {
              httpurl += this.url.edit
              method = 'put'
            }
            httpAction(httpurl, this.model, method).then((res) => {
              if (res.success) {
                that.$message.success(res.message)
                that.$emit('ok')
              } else {
                that.$message.warning(res.message)
              }
            }).finally(() => {
              that.confirmLoading = false
              that.close()
            })
          } else {
            return false
          }
        })
      },
      handleCancel() {
        this.close()
      },

    }
  }
</script>

<style lang="less" scoped>

</style>